// pages/coupondetails/details.js
const api = require("../../utils/interface.js")
const math = require("../../utils/math.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    timeOut:"",//到期时间
    productName:"",//油品类型
    storeName:"",//可用油站
    preAmount:"",//优惠金额
    couponName:"",//优惠券名称
    paytypeList:"",
    receiveTime:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options,"55")
    let memberCouponId =options.memberCouponId
    this.getOrderList(memberCouponId)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  getOrderList(item){
    let that=this
    api.getByMemberCouponIdForOrder({ memberCouponId:item}).then(res => {
     console.log(res,"yang")
     let storeList=res.data.result.storeName.split(",")
     let paytypeList = res.data.result.payTypes.split(",")
      let receiveTime = res.data.result.receiveTime
     let timeOut=res.data.result.timeOut
     let productName=res.data.result.productName
      let preAmount = math.divide(res.data.result.preAmount, 100)
      let couponName = res.data.result.couponName
     that.setData({
       timeOut:timeOut,
       productName:productName,
       storeName:storeList,
       paytypeList:paytypeList,
       receiveTime,
       preAmount,
       couponName
     })
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})